// search-book.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    history:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var history = wx.getStorageSync('history')
    this.setData({
      history: history
    })
  },

  tapCancle: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  openSearch:function(e){
    var word=e.detail.value.keyword
    this.setSearchStorage(word)
    wx.navigateTo({
      url: '../booklist/booklist?word='+word,
    })

  },
  setSearchStorage: function (word) {

    var that = this
    if (word != '') {
      var searchData = wx.getStorageSync('history') || []
      searchData.push(word)
      wx.setStorageSync('history', searchData)
    }
  }
})
